import React, { PureComponent } from 'react';
import { Button, Row, Col, Tag } from 'antd';
import { routerRedux } from 'dva/router';

import Result from '../../../components/Result';
import styles from './style.less';

export default class Step3 extends PureComponent {
  render() {
    const { dispatch, data } = this.props;

    const onFinish = () => {
      dispatch(routerRedux.push('/type/add-type'));
    };

    const information = (
      <div className={styles.information}>
        <Row>
          <Col span={8} className={styles.label}>资产类型名称：</Col>
          <Col span={16}>{data.step1.type_name}</Col>
        </Row>
        <Row>
          <Col span={8} className={styles.label}>资产类型属性：</Col>
          <Col span={16}>
            {
              data.step2.type_attr.map((attr) => {
                return (
                  <Tag key={attr.id}>
                    {attr}
                  </Tag>
                );
              })
            }
          </Col>
        </Row>
      </div>
    );
    const actions = (
      <div>
        <Button type="primary" onClick={onFinish}>
          继续增加资产类型
        </Button>
        <Button>
          查看操作记录
        </Button>
      </div>
    );
    return (
      <Result
        type="success"
        title="新增类型成功"
        description="可在类型列表中查看新增的类型"
        extra={information}
        actions={actions}
        className={styles.result}
      />
    );
  }
}

